using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Text;

namespace SimplePostApp
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Post url file");
                return;
            }

            string url = args[0];
            string file = args[1];

            if (false == File.Exists(file))
            {
                Console.WriteLine("File does not exist");
                return;
            }

            StreamReader reader = new StreamReader(file);
            string contents = reader.ReadToEnd();
            reader.Close();

            HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create(url);
            request.Method = "POST";
            Stream requestStream = request.GetRequestStream();
            byte[] buffer = ASCIIEncoding.ASCII.GetBytes(contents);
            requestStream.Write(buffer, 0, buffer.Length);
            requestStream.Close();

            HttpWebResponse response = (HttpWebResponse) request.GetResponse();
            if (HttpStatusCode.OK == response.StatusCode)
            {
                Console.WriteLine("Done!");
            }
            else
            {
                Console.WriteLine("Error");
            }
        }
    }
}
